<div id="thing-list">
<h1>Listing things</h1>

<table width="75%" align="center" >
  <tr>
  	<td>
  		<%= link_to 'New thing', :action => 'new' %>
  	</td>
  </tr>
</table>

<table width="75%" align="center" border="1">
  <tr>
	<td>
		<%= link_to 'All', :action=> 'list', :id => nil %>
	</td>
	<td>
		<%= link_to 'Priva', :action=> 'list', :id => 'private' %>
	</td>
	<td>
		<%= link_to 'Work', :action=> 'list', :id => 'work' %>
	</td>
	<td>
		<%= link_to 'Life', :action=> 'list', :id => 'life' %>
	</td>
	<td>
		<%= link_to 'Learn', :action=> 'list', :id => 'learn' %>
	</td>
	<td>
		<%= link_to 'Other', :action=> 'list', :id => 'other' %>
	</td>
  </tr>
</table>

<table width="75%" align="center" >
  <tr>
  <% for column in Thing.content_columns %>
    <% if ( column.human_name == 'Title' || 
			column.human_name == 'Deadline' ||
			column.human_name == 'Priority' || 
			column.human_name == 'Category' ) %>
    	<th><%= column.human_name %></th>
	<% end %>
  <% end %>
  </tr>
  
<% for thing in @things %>
  <% if thing.priority <= 2 %>
  <% if thing.deadline == Date.today %>
  <tr valign="top" class="list-line-today" >
  <% else %>
  <tr valign="top" class="<%= cycle('list-line-odd', 'list-line-even') %>" >
  <% end %>

  <% for column in Thing.content_columns %>
    <% if column.human_name == 'Title' %>
    	<td>
    		<%= link_to (thing.send(column.name)), 
				:action => 'show', :id => thing %>
		</td>
	<% end %>
	<% if ( column.human_name == 'Deadline' || 
			column.human_name == 'Priority' || 
			column.human_name == 'Category' ) %>
    	<td><%= thing.send(column.name) %></td>
	<% end %>
  <% end %>
  </tr>
  <% end %>
<% end %>

  <tr>
  	<td>
  		<br>
	</td>
  </tr>

  <tr>
  <% for column in Thing.content_columns %>
    <% if ( column.human_name == 'Title' || 
			column.human_name == 'Deadline' ||
			column.human_name == 'Priority' || 
			column.human_name == 'Category' ) %>
    	<th><%= column.human_name %></th>
	<% end %>
  <% end %>
  </tr>
  
<% for thing in @things %>
  <% if thing.priority >= 3 %>
  <% if thing.deadline == Date.today %>
  <tr valign="top" class="list-line-today" >
  <% else %>
  <tr valign="top" class="<%= cycle('list-line-odd', 'list-line-even') %>" >
  <% end %>
  
  <% for column in Thing.content_columns %>
    <% if column.human_name == 'Title' %>
    	<td>
    		<%= link_to (thing.send(column.name)), 
				:action => 'show', :id => thing %>
		</td>
	<% end %>
	<% if ( column.human_name == 'Deadline' || 
			column.human_name == 'Priority' || 
			column.human_name == 'Category' ) %>
    	<td><%= thing.send(column.name) %></td>
	<% end %>
  <% end %>
  </tr>
  <% end %>
<% end %>

  <tr>
  	<td>
  		<br>
	</td>
  </tr>

  <tr>
  	<td>
      <% if @thing_pages.current.previous %>
      <%= link_to 'Previous', { :page => @thing_pages.current.previous } %>
      <% else %>
      <%= 'Previous' %>
      <% end %>
      <%= "||" %>
      <% if @thing_pages.current.next %>
      <%= link_to 'Next', { :page => @thing_pages.current.next } %>
      <% else %>
      <%= 'Next' %>
      <% end %>
  	</td>
  </tr>

</table>

</div>

<br>
